// CSS directly lifted from Grid repo

@use '../core' as *;

.searchResults {
    display: none;
    position: absolute;
    width: 100%;
    max-width: calc(100vw - $spacing-size-8);
    max-height: 24rem;
    top: 48px;
    left: 0;
    border-bottom-right-radius: var(--radius-sm);
    border-bottom-left-radius: var(--radius-sm);
    background-color: var(--color-bg-primary);
    border-top: 1px solid var(--color-border-primary);
    overflow-y: auto;
    z-index: 999;
    box-shadow: inset 0 -1px 0 0 var(--color-border-primary);

    @media screen and (min-width: $breakpoint-docs-search-medium) {
        top: 38px;
        border-top: none;
    }

    li {
        line-height: var(--text-lh-tight);
        margin-bottom: -1px;
    }

    li:first-child a {
        border-top: none;
    }

    a,
    .resultsMessage,
    :global(.ais-InfiniteHits-loadMore) {
        position: relative;
        display: block;
        padding: $spacing-size-4;
        border: 1px solid var(--color-border-primary);
        background-color: transparent;
        outline: none;
        transition:
            color $transition-default-timing,
            background-color $transition-default-timing,
            border-color $transition-default-timing;

        &:focus,
        &:focus-visible {
            position: relative;
            border-color: var(--color-input-border-hover);
            background-color: var(--color-util-gray-50);
            z-index: 1002;
        }

        &:disabled {
            display: none;
        }
    }

    a,
    a:hover {
        color: var(--color-text-primary);
    }

    h4 {
        margin-bottom: $spacing-size-1;
        font-weight: var(--text-bold);
    }

    a:hover h4,
    a:hover .breadcrumb {
        color: var(--color-link);
        transition: color $transition-default-timing;
    }

    mark {
        background-color: transparent;
        padding: 0;
    }

    &.isOpen {
        display: block;
    }

    #{$selector-darkmode} & {
        --color-border-primary: var(--color-input-border);

        top: 40px;
        box-shadow: inset 0 -1px 0 0 var(--color-border-primary);
    }
}

.breadcrumb {
    color: var(--color-fg-secondary);
}

:global(.ais-InfiniteHits-list) {
    margin-bottom: 0;
    padding-left: 0;
    list-style: none;
}

:global(.ais-Highlight-highlighted),
:global(.ais-Snippet-highlighted) {
    color: var(--color-link);
    font-weight: var(--text-bold);
}

button:global(.ais-InfiniteHits-loadMore) {
    width: 100%;
    padding: $spacing-size-1;
    border-top-right-radius: 0;
    border-top-left-radius: 0;
    font-weight: var(--text-regular);
    color: var(--color-link);
    box-shadow: none;
    transition: background-color $transition-default-timing;

    &:hover {
        background-color: var(--color-util-brand-50);
    }
}

.hitCount {
    position: absolute;
    display: none;
    top: 2px;
    right: 2px;
    padding: 8px 8px 9px 8px;
    font-size: var(--text-fs-sm);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.33s ease-in-out;

    @media screen and (min-width: $breakpoint-docs-search-medium) {
        display: inline-block;
    }

    &.hasResults {
        opacity: 1;
    }
}

.resultsMessage {
    border-top: none;
}
